﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace TonyNet4V1.SQLServer
{
	/// <summary>
	/// 表结构数据类
	/// </summary>
	public class TableStructureDB
	{
		private DBOperation clsDB;

		public TableStructureDB(System.Web.UI.Page page)
		{
			clsDB = new DBOperation(page);
		}

		public DataTable GetStructure(string strTableName)
		{
			string strSQL;

			strSQL = "SELECT SysColumns.name AS ColumnName, systypes.name AS ColumnType, Syscolumns.length AS ColumnLength  FROM SysColumns LEFT JOIN systypes ON (SysColumns.xtype = systypes.xtype) WHERE id=Object_Id('" + strTableName + "') ";
			return clsDB.Query(strSQL);
		}
	}
}
